﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace SelfService.DataAccess.Migrations
{
    public partial class 新增医疗项目新增任务管理 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<Guid>(
                name: "PayId",
                table: "SysOrders",
                type: "char(36)",
                nullable: true,
                collation: "ascii_general_ci");

            migrationBuilder.CreateTable(
                name: "SysMedicalProjects",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Name = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Number = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Price = table.Column<decimal>(type: "decimal(12,6)", nullable: false),
                    IsControlQty = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysMedicalProjects", x => x.ID);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SysTasks",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ClassName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TaskType = table.Column<int>(type: "int", nullable: false),
                    LastRunTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    LastEndTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    NextRunTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    TimeType = table.Column<int>(type: "int", nullable: false),
                    Interval = table.Column<TimeSpan>(type: "time(6)", nullable: false),
                    LastRunResult = table.Column<int>(type: "int", nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    IsEnable = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    IsRun = table.Column<bool>(type: "tinyint(1)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysTasks", x => x.ID);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_SysOrders_PayId",
                table: "SysOrders",
                column: "PayId");

            migrationBuilder.AddForeignKey(
                name: "FK_SysOrders_SysPays_PayId",
                table: "SysOrders",
                column: "PayId",
                principalTable: "SysPays",
                principalColumn: "ID");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysOrders_SysPays_PayId",
                table: "SysOrders");

            migrationBuilder.DropTable(
                name: "SysMedicalProjects");

            migrationBuilder.DropTable(
                name: "SysTasks");

            migrationBuilder.DropIndex(
                name: "IX_SysOrders_PayId",
                table: "SysOrders");

            migrationBuilder.DropColumn(
                name: "PayId",
                table: "SysOrders");
        }
    }
}
